﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EHTSaleManager.Code.Entity;
using EHTSaleManager.Code.DAL;
using System.Data.SqlClient;
using System.Data;

namespace EHTSaleManager.Code.BLL
{
    public class SupportsProvider
    {
        public static void IUSupports(Support theSupport, bool IsAdd)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_IUSupports";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@ID", theSupport.ID));
            command.Parameters.Add(new SqlParameter("@Note", theSupport.Note));
            command.Parameters.Add(new SqlParameter("@Skype", theSupport.Skype));
            command.Parameters.Add(new SqlParameter("@Yahoo", theSupport.Yahoo));
            command.Parameters.Add(new SqlParameter("@GTalk", theSupport.GTalk));
            command.Parameters.Add(new SqlParameter("@IsAdd", IsAdd));

            DataProvider.ExecuteNoneQuery(command);
        }
        public static void DeleteSupports(Int32 ID)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_DeleteSupportsByID";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@ID", ID));

            DataProvider.ExecuteNoneQuery(command);
        }
        public static DataSet GetSupports()
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_GetSupports";
            command.CommandType = CommandType.StoredProcedure;

            return DataProvider.ExecuteDataSet(command);
        }
         public static Support GetSupportsbyID(int ID)
        {
           SqlCommand command = new SqlCommand();
           command.CommandText = "proc_GetSupportByID";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@ID",ID));

            DataSet ds = DataProvider.ExecuteDataSet(command);
            Support theSupport = null;

            if (ds.Tables[0].Rows.Count > 0)
            {
                theSupport = new Support();
                theSupport.ID = Int32.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                theSupport.Note = ds.Tables[0].Rows[0]["Note"].ToString();
                theSupport.Skype = ds.Tables[0].Rows[0]["Skype"].ToString();
                theSupport.Yahoo = ds.Tables[0].Rows[0]["Yahoo"].ToString();
                theSupport.GTalk = ds.Tables[0].Rows[0]["GTalk"].ToString();
            }

            return theSupport;
        }
        

    }
}